<?php

namespace App\Models;

use Eloquent as Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * Class Category
 * @package App\Models
 * @version September 12, 2017, 1:24 pm UTC
 *
 * @property integer parent_id
 * @property integer order
 * @property string name
 * @property string slug
 * @property string image
 */
class Category extends Model
{
    use SoftDeletes;

    public $table = 'categories';
    

    protected $dates = ['deleted_at'];


    public $fillable = [
        'shop_id',
        'parent_id',
        'sort',
        'name',
        'slug',
        'is_in_list',
        'image'
    ];

    /**
     * The attributes that should be casted to native types.
     *
     * @var array
     */
    protected $casts = [
        'parent_id' => 'integer',
        'sort' => 'integer',
        'name' => 'string',
        'slug' => 'string',
        'image' => 'string'
    ];

    /**
     * Validation rules
     *
     * @var array
     */
    public static $rules = [
        
    ];

    public function goods()
    {
        return $this->belongsToMany('App\Models\Goods','category_goods','cat_id','goods_id');
    }

    public function parent()
    {
        return $this->belongsTo('App\Models\Category','cat_id');
    }
}
